package math

import (
	"lesson01/instructions/base"
	"lesson01/rtda"
)

type IInc struct {
	Index uint
	Const int32
}

func (e *IInc) FetchOperands(reader *base.BytecodeReader) {
	e.Index = uint(reader.ReadUint8())
	e.Const = int32(reader.ReadInt8())
}

func (e *IInc) Execute(frame *rtda.Frame) {
	localVars := frame.LocalVars()
	val := localVars.GetInt(e.Index)
	val += e.Const
	localVars.SetInt(e.Index, val)
}
